<?php

namespace App\Models;

use App\Models\airline\base\BanModel;
use App\Models\airline\base\PortModel;
use App\Models\base\WarehouseModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model as BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;


class DestinationRuleModel extends BaseModel
{
    use HasFactory, SoftDeletes;

    protected $table = 't_destination_rule';

    protected $primaryKey = 'id';

    public $timestamps = true;

    const CREATED_AT = 'created_at';
    
    const UPDATED_AT = null;

    protected $guarded = [];

    protected $hidden = [
        'deleted_at',
    ];

    //规则 1PIVOT 2价格最低 3客户偏好
    const RULE_PIVOT = 1;
    const RULE_PRICE = 2;
    const RULE_CUSTOMER = 3;
    const RULE_MAPS = [
        self::RULE_PIVOT => 'PIVOT',
        self::RULE_PRICE => '价格最低',
        self::RULE_CUSTOMER => '客户偏好'
    ];


    //创建人
    public function create_admin(): BelongsTo {
        return $this->belongsTo(AdminModel::class, 'created_admin_id');
    }

    //目的地国家
    public function country(): BelongsTo {
        return $this->belongsTo(CountryModel::class, 'country_id');
    }

    //目的地口岸
    public function port(): BelongsTo {
        return $this->belongsTo(PortModel::class, 'port_id');
    }

}
